package com.vizhuo.client.business.match.goods.vo;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.vizhuo.client.base.AbstractVo;
import com.vizhuo.client.business.match.goods.constant.addOrderConstant;
import com.vizhuo.client.business.meb.mebacc.vo.MebAccVo;
import com.vizhuo.client.util.ClientUtil;

/**
 * 
 * @ClassName: GoodsObjVo
 * @Description: 订单管理-货源信息
 * @author luzh
 * @date 2015-7-9 下午1:56:12
 * 
 */
public class MatGoodsVo extends AbstractVo implements Serializable {

    /**
     * 主键订单id
     */
    private Long id;

    /**
     * 发货人VO对象
     */
    private MebAccVo mebAccSendVo;

    /**
     * 承运人VO对象
     */
    private MebAccVo mebAccCarrierVo;
    
    /**
     * 订单Vo（货运单号、等信息）
     */
    private MatOrderVo matOrderVo;


    /**
     * 货源编号,yyyyMMddxId (客户端不用传)
     */
    private String goodsNo;

    /**
     * 状态(客户端不用传)
     */
    private String state;

    /**
     * 状态-文本
     */
    private String stateName;

    /**
     * 运输起点省编码
     */
    private String startProvice;//

    /**
     * 运输起点市编码
     */
    private String startCity;//

    /**
     * 运输起点区编码
     */
    private String startCounty;//

    /**
     * 运输起点详细地址
     */
    private String startAddress;//

    /**
     * 运输起点经度(客户端不用传)
     */
    private String startLng;//

    /**
     * 运输起点纬度(客户端不用传)
     */
    private String startLat;//

    /**
     * 运输终点省编码
     */
    private String endProvice;//

    /**
     * 运输终点市编码
     */
    private String endCity;//

    /**
     * 运输终点区编码
     */
    private String endCounty;//

    /**
     * 运输终点详细地址
     */
    private String endAddress;//

    /**
     * 运输起始省市区名称
     */
    private String startAreaName;

    /**
     * 运输终点省市区名称
     */
    private String endAreaName;

    /**
     * 运输类型,1:干线,2:同城
     */
    private String runType;//

    /**
     * 运输终点经度(客户端不用传)
     */
    private String endLng;//

    /**
     * 运输终点纬度(客户端不用传)
     */
    private String endLat;//

    /**
     * 货物类型
     */
    private String goodsType;//

    /**
     * 货物类型
     */
    private String goodsSpecies;

    /**
     * 货物种类（名称）
     */
    private String goodsSpeciesLabel;

    /**
     * 货物类型-code
     */
    // private String goodsTypeCode;//


    /**
     * 货物重量(吨)
     */
    private Double goodsLoad;//

    /**
     * 货物体积(方)
     */
    private Double goodsSize;//

    /**
     * 件数
     */
    private Integer goodsPiece;

    /**
     * 推送承运方数量
     */
    private Integer pushSuccessCount;

    /**
     * 抢单数量
     */
    private Integer goodsCatchCount;

    /**
     * 需求车型
     */
    private String needCarType;//

    /**
     * 需求车型名称
     */
    private String needCarTypeLabel;

    /**
     * 需求车长
     */
    private String needCarLength;//

    /**
     * 用车时间
     */
    private String needCarTime;//

    /**
     * 下单时间
     */
    private String releaseTime;//

    /**
     * 用车需求文字描述
     */
    private String needDesc;//

    /**
     * 是否整车,1:是,0否,默认:否
     */
    private String isCarload;//

    /**
     * 是否仅通知车库中的司机,1:是,0否,默认否
     */
    private String isMycar;//

    /**
     * 货源摘要(客户端不用传)
     */
    private String goodsRemark;//

    /**
     * 用车需求语音描述url
     */
    private String needSoundUrl;//

    /**
     * 全程距离(米) 客户端不用传
     */
    private int distance;

    /**
     * 距你距离(米)
     */
    private int distanceYou;

    // extend
    private String carrierName;

    /**
     * 收货人姓名
     */
    private String receiptName;

    /**
     * 收货人电话
     */
    private String receiptPhone;

    /**
     * 收货人地址
     */
    private String receiptAddress;

    /**
     * 距离类型： 1:长途，2：同城
     */
    private String distanceType;

    /**
     * 距离类型： 0:按取货时间规则取货，1：随时可取
     */
    private String takeFlag;

    /**
     * 超时取货推送已经推送的时间
     */
    private Date takeTimeoutPushtime;

    /**
     * 特殊需求
     */
    private String needOther;

    /**
     * 距你距离(米)
     * 
     * @return
     */
    public int getDistanceYou() {
        return distanceYou;
    }

    /**
     * 距你距离(米)
     * 
     * @param distanceYou
     */
    public void setDistanceYou(int distanceYou) {
        this.distanceYou = distanceYou;
    }

    /**
     * 开始详细地址
     * 
     * @return
     */
    public String getStartAddress() {
        startAddress = (startAddress == null ? "" : startAddress);
        return startAddress.replaceAll("\n", "");
    }

    /**
     * 开始详细地址
     * 
     * @param startAddress
     */
    public void setStartAddress(String startAddress) {
        this.startAddress = startAddress;
    }

    /**
     * 运输起点经度(客户端不用传)
     * 
     * @return
     */
    public String getStartLng() {
        return startLng;
    }

    /**
     * 运输起点经度(客户端不用传)
     * 
     * @param startLng
     */
    public void setStartLng(String startLng) {
        this.startLng = startLng;
    }

    /**
     * 运输起点经纬度(客户端不用传)
     * 
     * @return
     */
    public String getStartLat() {
        return startLat;
    }

    /**
     * 运输起点纬度(客户端不用传)
     * 
     * @param startLat
     */
    public void setStartLat(String startLat) {
        this.startLat = startLat;
    }

    /**
     * 结束详细地址
     * 
     * @return
     */
    public String getEndAddress() {
        endAddress = (endAddress == null ? "" : endAddress);
        return endAddress.replaceAll("\n", "");
    }

    /**
     * 结束详细地址
     * 
     * @param endAddress
     */
    public void setEndAddress(String endAddress) {
        this.endAddress = endAddress;
    }

    /**
     * 运输终点经度(客户端不用传)
     * 
     * @return
     */
    public String getEndLng() {
        return endLng;
    }

    /**
     * 运输终点经度(客户端不用传)
     * 
     * @param endLng
     */
    public void setEndLng(String endLng) {
        this.endLng = endLng;
    }

    /**
     * 运输终点纬度(客户端不用传)
     * 
     * @return
     */
    public String getEndLat() {
        return endLat;
    }

    /**
     * 运输终点纬度(客户端不用传)
     * 
     * @param endLat
     */
    public void setEndLat(String endLat) {
        this.endLat = endLat;
    }

    /**
     * 货物类型-code 9003
     * 
     * @return
     */
    public String getGoodsType() {
        return goodsType;
    }

    /**
     * 货物种类
     * 
     * @param goodsType
     */
    public void setGoodsType(String goodsType) {
        this.goodsType = goodsType;
    }

    /**
     * 货物重量
     * 
     * @return
     */
    public double getGoodsLoad() {
        return goodsLoad;
    }

    /**
     * 货物重量
     * 
     * @param goodsLoad
     */
    public void setGoodsLoad(double goodsLoad) {
        this.goodsLoad = goodsLoad;
    }

    /**
     * 货物体积
     * 
     * @return
     */
    public double getGoodsSize() {
        return goodsSize;
    }

    /**
     * 货物体积
     * 
     * @param goodsSize
     */
    public void setGoodsSize(double goodsSize) {
        this.goodsSize = goodsSize;
    }

    /**
     * 需要车型-code
     * 
     * @return
     */
    public String getNeedCarType() {
        return needCarType;
    }

    /**
     * 需要车型
     * 
     * @param needCarType
     */
    public void setNeedCarType(String needCarType) {
        this.needCarType = needCarType;
    }

    /**
     * 需要车长
     * 
     * @return
     */
    public String getNeedCarLength() {
        return needCarLength == null ? "0" : needCarLength;
    }

    /**
     * 需要车长
     * 
     * @return
     */
    public String getNeedCarLengthName() {
        return needCarLength == null ? "0米" : needCarLength + "米";
    }

    /**
     * 需要车长
     * 
     * @param needCarLength
     */
    public void setNeedCarLength(String needCarLength) {
        this.needCarLength = needCarLength;
    }

    /**
     * 用车时间
     * 
     * @return
     */
    public String getNeedCarTime() {
        if (needCarTime == null || needCarTime.equals("")) {
            return needCarTime;
        }

        // 格式化用车时间，长途订单显示年月日，同城显示年月日时分
        DateFormat dfTongCheng = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        DateFormat dfChangTu = new SimpleDateFormat("yyyy-MM-dd");
        try {
            // 同城
            if (this.getDistanceType() != null && this.getDistanceType().equals(addOrderConstant.TYPE_SAME_CITY)) {
                Date dateTongCheng = dfTongCheng.parse(needCarTime);
                return dfTongCheng.format(dateTongCheng);
            } else {
                Date dateChangTu = dfChangTu.parse(needCarTime);
                return dfChangTu.format(dateChangTu);
            }
        } catch (ParseException e) {
            e.printStackTrace();
            return "";
        }


    }

    /**
     * 用车时间
     * 
     * @param needCarTime
     */
    public void setNeedCarTime(String needCarTime) {
        this.needCarTime = needCarTime;
    }

    /**
     * 用车描述
     * 
     * @return
     */
    public String getNeedDesc() {
        return ClientUtil.str(needDesc);
    }

    /**
     * 用车描述
     * 
     * @param needDesc
     */
    public void setNeedDesc(String needDesc) {
        this.needDesc = needDesc;
    }

    /**
     * 是否整车,1:是,0否,默认:否
     * 
     * @return
     */
    public String getIsCarload() {
        return isCarload;
    }

    /**
     * 是否整车,1:是,0否,默认:否
     * 
     * @param isCarload
     */
    public void setIsCarload(String isCarload) {
        this.isCarload = isCarload;
    }

    /**
     * 是否仅通知车库中的司机,1:是,0否,默认否
     * 
     * @return
     */
    public String getIsMycar() {
        return isMycar;
    }

    /**
     * 是否仅通知车库中的司机,1:是,0否,默认否
     * 
     * @param isMycar
     */
    public void setIsMycar(String isMycar) {
        this.isMycar = isMycar;
    }


    /**
     * 起点省编码
     * 
     * @return
     */
    public String getStartProvice() {
        return startProvice;
    }

    /**
     * 起点省编码
     * 
     * @param startProvice
     */
    public void setStartProvice(String startProvice) {
        this.startProvice = startProvice;
    }

    /**
     * 起点市编码
     * 
     * @return
     */
    public String getStartCity() {
        return startCity;
    }

    /**
     * 起点市编码
     * 
     * @param startCity
     */
    public void setStartCity(String startCity) {
        this.startCity = startCity;
    }

    /**
     * 起点区县编码
     * 
     * @return
     */
    public String getStartCounty() {
        return startCounty;
    }

    /**
     * 起点区县编码
     * 
     * @param startCounty
     */
    public void setStartCounty(String startCounty) {
        this.startCounty = startCounty;
    }

    /**
     * 终点省编码
     * 
     * @return
     */
    public String getEndProvice() {
        return endProvice;
    }

    /**
     * 终点省编码
     * 
     * @param endProvice
     */
    public void setEndProvice(String endProvice) {
        this.endProvice = endProvice;
    }

    /**
     * 终点市编码
     * 
     * @return
     */
    public String getEndCity() {
        return endCity;
    }

    /**
     * 终点市编码
     * 
     * @param endCity
     */
    public void setEndCity(String endCity) {
        this.endCity = endCity;
    }

    /**
     * 终点区县编码
     * 
     * @return
     */
    public String getEndCounty() {
        return endCounty;
    }

    /**
     * 终点区县编码
     * 
     * @param endCounty
     */
    public void setEndCounty(String endCounty) {
        this.endCounty = endCounty;
    }


    /**
     * 货源编号,yyyyMMddxId (客户端不用传)
     * 
     * @return
     */
    public String getGoodsNo() {
        return goodsNo;
    }

    /**
     * 货源编号,yyyyMMddxId (客户端不用传)
     * 
     * @param goodsNo
     */
    public void setGoodsNo(String goodsNo) {
        this.goodsNo = goodsNo;
    }

    /**
     * 货源摘要(客户端不用传)
     * 
     * @return
     */
    public String getGoodsRemark() {
        return goodsRemark;
    }

    /**
     * 货源摘要(客户端不用传)
     * 
     * @param goodsRemark
     */
    public void setGoodsRemark(String goodsRemark) {
        this.goodsRemark = goodsRemark;
    }

    /**
     * 主键(客户端不用传)
     * 
     * @return
     */
    public Long getId() {
        return id;
    }

    /**
     * 主键(客户端不用传)
     * 
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * 录音url(客户端不用传)
     * 
     * @return
     */
    public String getNeedSoundUrl() {
        return needSoundUrl;
    }

    /**
     * 录音url(客户端不用传)
     * 
     * @param needSoundUrl
     */
    public void setNeedSoundUrl(String needSoundUrl) {
        this.needSoundUrl = needSoundUrl;
    }

    /**
     * 全程距离(米) 客户端不用传
     * 
     * @return
     */
    public double getDistance() {
        return distance;
    }

    /**
     * 全程距离 客户端可以取这个,超过1000米,返回公里,小于1000米返回米
     * 
     * @return
     */
    public String getDistanceLabel() {
        if (distance > 1000) {
            return (distance / 1000) + "公里";
        } else {
            return distance + "米";
        }
    }

    /**
     * 距离你距离 客户端可以取这个,超过1000米,返回公里,小于1000米返回米
     * 
     * @return
     */
    public String getDistanceYouLabel() {
        if (distanceYou > 1000) {
            return ((float) distanceYou / 1000) + "公里";
        } else {
            return distanceYou + "米";
        }
    }

    /**
     * 全程距离(米) 客户端不用传
     * 
     * @param distance
     */
    public void setDistance(int distance) {
        this.distance = distance;
    }

    /**
     * 运输类型(客户端不用传),1:干线,2:同城
     * 
     * @return
     */
    public String getRunType() {
        return runType;
    }

    /**
     * 运输类型(客户端不用传),1:干线,2:同城
     * 
     * @param runType
     */
    public void setRunType(String runType) {
        this.runType = runType;
    }

    /**
     * 客户端货物类型调用该方法:处理 重量和体积的问题
     * 
     * @return
     */
    public String getGoodsLoadSizePieceLabel() {
        
        String goodsSpeciesLabelStr = "";
        if (this.getDistanceType() != null && (this.getDistanceType().equals(addOrderConstant.TYPE_SAME_CITY))) {
            // 同城

        } else {
            // 长途
            goodsSpeciesLabelStr = this.goodsSpeciesLabel == null ? "" : this.goodsSpeciesLabel;

            String goodsLoadStr = "";
            String goodsSizeStr = "";

            if (this.getGoodsLoad() == (int) this.getGoodsLoad()) {
                goodsLoadStr = String.valueOf((int) this.getGoodsLoad());
            } else {
                goodsLoadStr = String.valueOf(this.getGoodsLoad());
            }
            if (this.getGoodsSize() == (int) this.getGoodsSize()) {
                goodsSizeStr = String.valueOf((int) this.getGoodsSize());
            } else {
                goodsSizeStr = String.valueOf(this.getGoodsSize());
            }
            //
            // if ("1".equals(this.getGoodsType())) {
            // goodsTypeLabel += " " + goodsLoadStr + "吨";
            // } else {
            // goodsTypeLabel += " " + goodsSizeStr + "立方";
            // }
            if (goodsLoad != null && this.goodsLoad != 0.0) {
                goodsSpeciesLabelStr = goodsSpeciesLabelStr + " " + goodsLoadStr + "吨";
            }
            if (goodsSize != null && this.goodsSize != 0.0) {
                goodsSpeciesLabelStr = goodsSpeciesLabelStr + " " + goodsSizeStr + "立方";
            }
            if (goodsPiece != null && this.goodsPiece != 0) {
                goodsSpeciesLabelStr = goodsSpeciesLabelStr + " " + goodsPiece + "件";
            }

        }
        return goodsSpeciesLabelStr;
    }

    /**
     * 重量/提交
     * 
     * @return
     */
    public String getGoodsLoadSizeLabel() {
        /*
         * String goodsTypeLabel = ""; String goodsLoadStr = ""; String
         * goodsSizeStr = ""; if (this.getGoodsLoad() == (int)
         * this.getGoodsLoad()) { goodsLoadStr = String.valueOf((int)
         * this.getGoodsLoad()); } else { goodsLoadStr =
         * String.valueOf(this.getGoodsLoad()); } if (this.getGoodsSize() ==
         * (int) this.getGoodsSize()) { goodsSizeStr = String.valueOf((int)
         * this.getGoodsSize()); } else { goodsSizeStr =
         * String.valueOf(this.getGoodsSize()); } if
         * ("1".equals(this.getGoodsType())) { goodsTypeLabel = goodsLoadStr +
         * "吨"; } else { goodsTypeLabel = goodsSizeStr + "立方"; } return
         * goodsTypeLabel;
         */

        String goodsSpeciesLabelStr = "";
        String goodsLoadStr = "";
        String goodsSizeStr = "";

        if (this.getGoodsLoad() == (int) this.getGoodsLoad()) {
            goodsLoadStr = String.valueOf((int) this.getGoodsLoad());
        } else {
            goodsLoadStr = String.valueOf(this.getGoodsLoad());
        }
        if (this.getGoodsSize() == (int) this.getGoodsSize()) {
            goodsSizeStr = String.valueOf((int) this.getGoodsSize());
        } else {
            goodsSizeStr = String.valueOf(this.getGoodsSize());
        }
        if (goodsLoad != null && this.goodsLoad != 0.0) {
            goodsSpeciesLabelStr = goodsSpeciesLabelStr + " " + goodsLoadStr + "吨";
        }
        if (goodsSize != null && this.goodsSize != 0.0) {
            goodsSpeciesLabelStr = goodsSpeciesLabelStr + " " + goodsSizeStr + "立方";
        }
        if (goodsPiece != null && this.goodsPiece != 0) {
            goodsSpeciesLabelStr = goodsSpeciesLabelStr + " " + goodsPiece + "件";
        }
        return goodsSpeciesLabelStr;

    }

    // public String getGoodsTypeCode() {
    // return goodsTypeCode;
    // }
    //
    // public void setGoodsTypeCode(String goodsTypeCode) {
    // this.goodsTypeCode = goodsTypeCode;
    // }

    public String getReleaseTime() {
        if (releaseTime != null) {
            releaseTime = releaseTime.replace(".0", "");
        }
        return releaseTime;
    }

    public void setReleaseTime(String releaseTime) {
        this.releaseTime = releaseTime;
    }

    public String getGoodsSpecies() {
        return goodsSpecies;
    }

    public void setGoodsSpecies(String goodsSpecies) {
        this.goodsSpecies = goodsSpecies;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getGoodsSpeciesLabel() {
        return goodsSpeciesLabel;
    }

    public void setGoodsSpeciesLabel(String goodsSpeciesLabel) {
        this.goodsSpeciesLabel = goodsSpeciesLabel;
    }

    public String getCarrierName() {
        return ClientUtil.str(carrierName);
    }

    public void setCarrierName(String carrierName) {
        this.carrierName = carrierName;
    }

    /**
     * 收货人姓名
     * 
     * @return
     */
    public String getReceiptName() {
        return receiptName == null ? "" : receiptName;
    }

    /**
     * 收货人姓名
     * 
     * @param receiptName
     */
    public void setReceiptName(String receiptName) {
        this.receiptName = receiptName;
    }

    /**
     * 收货人电话
     * 
     * @return
     */
    public String getReceiptPhone() {
        return receiptPhone == null ? "" : receiptPhone;
    }

    /**
     * 收货人电话
     * 
     * @param receiptPhone
     */
    public void setReceiptPhone(String receiptPhone) {
        this.receiptPhone = receiptPhone;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public MebAccVo getMebAccSendVo() {
        return mebAccSendVo;
    }

    public void setMebAccSendVo(MebAccVo mebAccSendVo) {
        this.mebAccSendVo = mebAccSendVo;
    }

    public MebAccVo getMebAccCarrierVo() {
        return mebAccCarrierVo;
    }

    public void setMebAccCarrierVo(MebAccVo mebAccCarrierVo) {
        this.mebAccCarrierVo = mebAccCarrierVo;
    }

    public String getStartAreaName() {
        return startAreaName;
    }

    public void setStartAreaName(String startAreaName) {
        this.startAreaName = startAreaName;
    }

    public String getEndAreaName() {
        return endAreaName;
    }

    public void setEndAreaName(String endAreaName) {
        this.endAreaName = endAreaName;
    }

    public Integer getGoodsPiece() {
        return goodsPiece;
    }

    public void setGoodsPiece(Integer goodsPiece) {
        this.goodsPiece = goodsPiece;
    }

    public Integer getPushSuccessCount() {
        return pushSuccessCount;
    }

    public void setPushSuccessCount(Integer pushSuccessCount) {
        this.pushSuccessCount = pushSuccessCount;
    }

    public Integer getGoodsCatchCount() {
        return goodsCatchCount;
    }

    public void setGoodsCatchCount(Integer goodsCatchCount) {
        this.goodsCatchCount = goodsCatchCount;
    }

    public MatOrderVo getMatOrderVo() {
        return matOrderVo;
    }

    public void setMatOrderVo(MatOrderVo matOrderVo) {
        this.matOrderVo = matOrderVo;
    }

    public String getDistanceType() {
        return distanceType;
    }

    public void setDistanceType(String distanceType) {
        this.distanceType = distanceType;
    }

    public String getReceiptAddress() {
        return receiptAddress == null ? "" : receiptAddress;
    }

    public void setReceiptAddress(String receiptAddress) {
        this.receiptAddress = receiptAddress;
    }

    public String getNeedCarTypeLabel() {
        return needCarTypeLabel;
    }

    public void setNeedCarTypeLabel(String needCarTypeLabel) {
        this.needCarTypeLabel = needCarTypeLabel;
    }

    public String getTakeFlag() {
        return takeFlag;
    }

    public void setTakeFlag(String takeFlag) {
        this.takeFlag = takeFlag;
    }

    public Date getTakeTimeoutPushtime() {
        return takeTimeoutPushtime;
    }

    public void setTakeTimeoutPushtime(Date takeTimeoutPushtime) {
        this.takeTimeoutPushtime = takeTimeoutPushtime;
    }

    public String getNeedOther() {
        return needOther == null ? "" : needOther;
    }

    public void setNeedOther(String needOther) {
        this.needOther = needOther;
    }

}
